package com.luguokong.pet_rescue.service;

import com.luguokong.pet_rescue.mapper.OrderMapper;
import com.luguokong.pet_rescue.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

    public int insertOrder(Order order){
        int i = orderMapper.insertOrder(order);
        return i;
    }
    public int deleteOrderById(int order_id){
        int i = orderMapper.deleteOrderById(order_id);
        return i;
    }
    public int updateOrderById(Order order){
        int i = orderMapper.updateOrderById(order);
        return i;
    }
    public List<Order> selectOrderAllByUserId(int user_id){
        List<Order> orderList = orderMapper.selectOrderAllByUserId(user_id);
        return orderList;
    }
    public Order selectOrderById(int order_id){
        Order order = orderMapper.selectOrderById(order_id);
        return order;
    }
    public List<Order> selectOrderAll(){
        List<Order> orderList = orderMapper.selectOrderAll();
        return orderList;
    }
    public List<Order> selectOrderAllByDateByDesc(){
        List<Order> orderList = orderMapper.selectOrderAllByDateByDesc();
        return orderList;
    }

    public List<Order> selectOrderAllByPageNumByPageSize(int pageNum, int pageSize){
        List<Order> orderList = orderMapper.selectOrderAllByPageNumByPageSize(pageNum, pageSize);
        return orderList;
    }

    public int selectDataCount(){
        int i = orderMapper.selectDataCount();
        return i;
    }

    //    查询每个宠物类型的订单数量
    public List<Map<String, Number>> selectGroupByPetType(){
        List<Map<String, Number>> mapList = orderMapper.selectGroupByPetType();
        return mapList;
    }



}
